//
//  ZZCUbiController.m
//  ZZC-Finance
//
//  Created by mac on 2017/5/22.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ZZCUbiController.h"
#import "ZZCBuyUbiController.h"
#import "ZZCOwnPropertyController.h"
#import "ZZCWithdrawController.h"
#import "ZZCInspectController.h"
#import "ZZCTransferController.h"
#import "ZZCcurrentController.h"
#import "ZZCRegularUbiController.h"

@interface ZZCUbiController ()

@end

@implementation ZZCUbiController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self requestUbiData];
}

- (void)requestUbiData {
    NSString *token = ZZCNSUserDefaults(@"token");
    NSDictionary *dict = @{@"token":token};
    NSString *sign = [ZZCRequest getSignWithDict:dict];
    sign = [NSString md5:[sign lowercaseString]];
    NSDictionary *param = @{@"timestamp":[NSString timeStr],@"sign":sign,@"token":token};
    [[ZZCRequest sharedNetworkTools] POST:ZZCURL_API_MYASSET parameters:param finished:^(id  _Nullable responseObject, NSError * _Nullable error) {
        if (error) {
            ZZCLog(@"失败-%@",error);
        }else {
            ZZCLog(@"成功-%@",responseObject);
            self.UbiLabel.text = [NSString stringWithFormat:@"%@U币",responseObject[@"data"][@"current"][@"money"]];
            self.UbisLabel.text = [NSString stringWithFormat:@"%@U币",responseObject[@"data"][@"regular"]];
            self.rateLabel.text = [NSString stringWithFormat:@"%@%@",responseObject[@"data"][@"current"][@"rate"],@"%"];
            self.profitLabel.text = [NSString stringWithFormat:@"%@U币",responseObject[@"data"][@"current"][@"profit"]];
        }
    }];
}
#pragma mark - 按钮点击监听
//购买U币
- (IBAction)buyUbiClick {
    ZZCLog(@"你点击了--购买U币");
    ZZCBuyUbiController *ubi = [ZZCBuyUbiController new];
     [self pushVC:ubi];
}
//购买
- (IBAction)buyClick {
    ZZCLog(@"你点击了--购买按钮");
    ZZCBuyUbiController *ubi = [ZZCBuyUbiController new];
    [self pushVC:ubi];
}
//转账
- (IBAction)transferClick {
    ZZCLog(@"你点击了--转账按钮");
    ZZCTransferController *tra = [ZZCTransferController new];
    [self pushVC:tra];
}
//U币转定期
- (IBAction)incomeClick {
    ZZCLog(@"你点击了--转入按钮");
    ZZCRegularUbiController *reg = [ZZCRegularUbiController new];
    [self pushVC:reg];
}
//提现
- (IBAction)withdrawClick {
    ZZCLog(@"你点击了--提现按钮");
    ZZCWithdrawController *withdraw = [ZZCWithdrawController new];
    withdraw.moneyCount = self.UbiLabel.text;
    NSLog(@"%@",withdraw.moneyCount);
    [self pushVC:withdraw];
}

//查看
- (IBAction)inspectClick {
    ZZCLog(@"你点击了--查看按钮");
    ZZCInspectController *me = [ZZCInspectController new];
    [self pushVC:me];
}
//profitLabel
- (IBAction)expendClick {
    ZZCLog(@"你点击了--转出按钮");
    ZZCcurrentController *cur = [ZZCcurrentController new];
    [self pushVC:cur];
}

- (void)pushVC:(UIViewController *)VC {
     [self.parentController.navigationController pushViewController:VC animated:YES];
}
@end
